package cn.lingyangwl.agile.model.module.auth;

import cn.lingyangwl.agile.model.constants.UserCons;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * @author shenguangyang
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UserAccount implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 第三方授权登录第一次没有没有
     */
    public static final String NO_PASSWORD = "1";

    private String userName;
    private String email;
    private String phone;
    private String password;

    /**
     * 账号状态
     * @see UserCons.Status
     */
    private String status;

    public void setEmail(String email) {
        if (StringUtils.isEmpty(email)) {
            return;
        }
        this.email = email;
    }

    public void setPhone(String phone) {
        if (StringUtils.isEmpty(phone)) {
            return;
        }
        this.phone = phone;
    }

    public String getPassword() {
        return StringUtils.isEmpty(password) ? NO_PASSWORD : password;
    }
}
